﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ViewDonations.aspx.cs" Inherits="DonationTracker.ViewDonations" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Donations made to your charity</h2>
    <br /><br />
    <div id="gridContainer" style="width: 800px; max-width: 960px; margin: 0px auto;" >
        <asp:SqlDataSource ID="getCharities" runat="server" 
            ConnectionString="<%$ ConnectionStrings:DonationConn %>" 
            SelectCommand="SELECT [charityID], [name] FROM [charity] order by [order]"></asp:SqlDataSource>
        <asp:DropDownList ID="ddlCharities" runat="server" DataSourceID="getCharities" 
            DataTextField="name" DataValueField="charityID" AutoPostBack="true" 
            Visible="False" style="margin-bottom: 40px;" 
            onselectedindexchanged="ddlCharities_SelectedIndexChanged" >
        </asp:DropDownList>
        <asp:SqlDataSource ID="dsViewDonations" runat="server" 
            ConnectionString="<%$ ConnectionStrings:DonationConn %>" 
            SelectCommand="sp_ViewDonations" SelectCommandType="StoredProcedure" 
            CancelSelectOnNullParameter="False" >
                <SelectParameters>
                    <asp:Parameter Name="userID" />
                    <asp:Parameter DefaultValue="1012" Name="dropdown" Type="Int32" />
                </SelectParameters>
            </asp:SqlDataSource>

        <asp:GridView ID="gvViewDonations" runat="server" 
            style="max-height: 400px; width: 800px; margin: 0px auto;" 
            AutoGenerateColumns="False" 
            DataSourceID="dsViewDonations" AllowPaging="True" AllowSorting="True" >
            <Columns>
                <asp:BoundField DataField="donor" HeaderText="donor" 
                    SortExpression="donor" ReadOnly="True" />
                <asp:BoundField DataField="description" HeaderText="description" 
                    SortExpression="description" />
                <asp:BoundField DataField="event" HeaderText="event" 
                    SortExpression="event" />
                <asp:BoundField DataField="dateEntered" DataFormatString="{0:d}" 
                    HeaderText="dateEntered" SortExpression="dateEntered" />
                <asp:BoundField DataField="enteredBy" HeaderText="enteredBy" 
                    SortExpression="enteredBy" />
            </Columns>
        </asp:GridView>
    </div>
</asp:Content>
